package com.qiwx.pigeon.adapter.manager;

import android.widget.CheckBox;
import android.widget.CompoundButton;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.qiwx.pigeon.R;
import com.qiwx.pigeon.data.db.WareHouseModel;
import com.qiwx.pigeon.data.vo.CageBean;
import com.qiwx.pigeon.data.vo.CageBeanVo;

import java.util.ArrayList;
import java.util.List;

/**
 * @description
 * @Author qiwx
 * @Date 2020-03-24 16:15
 * 鸽笼管理 Adapter
 **/
public class CageAdapter extends BaseQuickAdapter<CageBeanVo, BaseViewHolder> {

    List<CageBeanVo> data = null;

    public CageAdapter(int layoutResId) {
        super(layoutResId);
    }

    public CageAdapter(int layoutResId, List<CageBeanVo> data) {
        super(layoutResId, data);
        this.data = data;

    }

    @Override
    protected void convert(BaseViewHolder holder, CageBeanVo bean) {

        holder.setText(R.id.txt_number_value, bean.getNumber() + "");
        String statusDes;
        int status = bean.getStatus();
        int drawableId = 0;
        if (status == 0) {
            statusDes = "空笼";
            drawableId = R.drawable.btn_status_green_color_round32;
        } else {
            statusDes = "存栏";
            drawableId = R.drawable.btn_status_red_color_round32;

        }
        holder.setText(R.id.txt_status, statusDes);
        holder.setBackgroundResource(R.id.txt_status, drawableId);
        CheckBox checkBox = holder.getView(R.id.cb_choice);
        checkBox.setChecked(bean.isSelected());

    }
}
